package com.wee.cronos.client.core.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;
import com.gwtplatform.mvp.client.ViewImpl;
import com.wee.cronos.client.core.presenter.WorkspacePresenter;
import com.wee.cronos.client.core.presenter.WorkspacePresenter.WorkspaceView;

public class WorkspaceViewImpl extends ViewImpl implements WorkspaceView
{
	interface WorkspaceViewUiBinder extends UiBinder<Widget, WorkspaceViewImpl> {}
	
	protected static final WorkspaceViewUiBinder uiBinder = GWT.create(WorkspaceViewUiBinder.class);
	
	public Widget widget;
	
	@UiField
	FlowPanel workspacePanel;
	
	public WorkspaceViewImpl()
	{
		widget = uiBinder.createAndBindUi(this);
	}
	
	@Override
	public Widget asWidget() 
	{
		return widget;
	}
	
	@Override
	public void setInSlot(Object slot, Widget content) 
	{
		if (slot == WorkspacePresenter.TYPE_RevealProjectMagenent) 
		{
			setProjectManagement(content);
	    } 
		else 
	    {
	    	super.setInSlot(slot, content);
	    }
	}
	
	public void setProjectManagement(Widget content)
	{
		workspacePanel.clear();
		
 		if(workspacePanel != null)
		{
			workspacePanel.add(content);
		}
	}
}
